<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>北京站智能网格化管理系统</title>
    <link rel="stylesheet" type="text/css" href="../lib/css/common.css">
    <link rel="stylesheet" href="../lib/css/iconFont/iconfont.css">
    <link rel="stylesheet" href="../lib/css/pagination.css">
    <link rel="stylesheet" type="text/css" href="../lib/css/station.css">
    <link rel="stylesheet" type="text/css" href="../lib/css/jquery.datetimepicker.css">
    <link rel="stylesheet" type="text/css" href="../lib/css/select2.min.css">
    <link rel="stylesheet" type="text/css" href="../lib/css/newcount.css"> 
</head>
<body>
<div class="station_grid wraper">
    <div class="searchwrap">
        <!-- 日期时间 -->
        <div class="searchelm searchtime1">
            <input type="text" id="datetimepicker" class="search_control" name="ptime_start">
            <input type="text" id="datetimepicker2" class="search_control" name="ptime_end">
            <div class="select2_wrap" style="min-width:15rem;max-width:60%;">
                <select name="wxdep" id="wxdep" class="search_control wxdep" style="width:100%">
                </select>
            </div>
            <!-- <select name="wxdep" id="wxdep" class="select_option wxdep" style="width:12rem;">
                <option value="1" checked>防修车间</option>
                <option value="2">信息化车间车间</option>
            </select> -->
            <input type="button" value="查询" id="lookUp1" class="lookUp"/>
        </div>
        <!-- 图表导出 切换 -->
        <div class="tabbar clearfix">
            <ul class="tab">
                <li class="tab_li tab_li_click" data-rel="1"><i class="icon iconfont icon-biaoge"></i>表格</li>
                <li class="tab_li" id="export_file" data-rel="2"><i class="icon iconfont icon-daochu"></i>导出</li>
            </ul>
        </div> 
    </div>
    <!-- echarts统计图表 -->
    <div class="main_content">
        <!-- 人员表格 -->
        <div class="station_shaow_detail nan">
            <table class="station_shaow_detail_table">
                <caption style="font-size: 2.4rem;">设备部门维修时间统计表</caption>
            </table>
                <div class="M-box1" style="font-size:10px;text-align:center;" id="page_string">
            </div>
        </div>
        <div class="lds-css block">
            <div class="lds-dual-ring">
                <div></div>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript" src="../lib/js/jquery-1.8.3.min.js"></script>
<script type="text/javascript" src="../lib/js/base.js"></script>
<script type="text/javascript" src="../lib/js/datetimepicker.js"></script>
<script type="text/javascript" src="../lib/js/jquery.pagination.js"></script>
<script type="text/javascript" src="../lib/js/select2.full.min.js"></script>
<script type="text/javascript" src="../lib/js/count.js"></script>
<script  type="text/javascript">   
//查询
var page = 1,postDep='0'
$("#lookUp1").click(function () {
    var _data = {
        'page':page,
        'start':$('#datetimepicker').val(),
        'end':$('#datetimepicker2').val(),
        'departments': $('#wxdep').val()==null?[]:$('#wxdep').val()
        // 'time':<?php echo time();?>,
    };
    devicePostRepairTable(_data)
});
//表格
function devicePostRepairTable(data){
    $('.lds-css').addClass('block')
    var _data = data
    $.ajax({
        url: serverUrl.base + serverUrl.count+'repair_time_table',
        type:"POST",
        data: _data,
        dataType:"json",
        success: function (res) {
            $('.lds-css').removeClass('block')
            // 根据数据库取到结果拼接现在结果
            var _data = res.data
            $('.station_shaow_detail_table').createTable({data:_data,columns:[
                {name:'序号',field:'',ids:1,w:'4rem'},
                {name:'设备名称',field:'device_name',w:'4rem'},
                {name:'设备所属部门',field:'department_name',w:'10rem'},
                {name:'维修所用时间',field:'repair_time',w:'10rem'},
                {name:'验收所用时间',field:'inspect_time',w:'8rem'},
                {name:'维修总时间',field:'all_time',w:'8rem'}
            ]})
            $("#page_string").html(res.result_page);
        }
    });
}

function common_request(elm){
    if(arguments[0]){
        page = arguments[0]
    }else{
        page = 1
    }
   $("#lookUp1").trigger('click')  
}
common_request()
//查询
function search_(){
    page = 1 ;
    common_request(1);  
}
//tab初始化
$('.tab .tab_li').each(function(index,elm){
    //console.log(index,elm)
    $(this).data('val',index)
})
//图表切换后的操作
$('.tab_li').on('click',function(elm){
    var $this = $(this)
    var _ids = $this.data('rel')?$this.data('rel'):$this.index()
    if(_ids== '1'){
        $(".educe").addClass("addli");
    }else if(_ids== '2'){
        //导出按钮
        var _data = {
            'start':$('#datetimepicker').val(),
            'end':$('#datetimepicker2').val(),
            'departments': $('#wxdep').val()==null?[]:$('#wxdep').val()
        };
        var _url=serverUrl.base + serverUrl.countD + 'repair_time_table?start='+encodeURIComponent(_data.start)+'&end='+encodeURIComponent(_data.end)+'&departments='+(encodeURIComponent(_data.departments) == 'null'?'':encodeURIComponent(_data.departments))
        window.location.href = _url;return;
    }
})
//设备管理部门
$('.wxdep').rpSelect({url:serverUrl.base+serverUrl.count+serverUrl.dep,multiple:true,placeholder:'请选择设备管理部门'})

</script>
</body>

</html>

